import { Define, EntityObjectFactory } from 'tiny-entity2';
import { Condition } from './condition';
import { Path } from './path';
import { WorkflowNodeItem } from './workflowNodeItem';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
@Define.Table({ TableName: "workflow" })
export class Workflow extends EntityObjectType<Workflow>{
    @Define.PrimaryKey()
    id: string;

    /**
     * 流程名称
     *
     * @type {string}
     * @memberof Workflow
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    name: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT,
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT,
    })
    updateTime: number;

    /**
     * 禁用启用状态
     *
     * @type {string}
     * @memberof Workflow
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    status: string;

    @Define.Column({
        DataType: Define.DataType.BOOL,
    })
    isDisable: boolean;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    orgId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    refPageId: string;

    @Define.Mapping({
        Mapping: 'Path',
        MappingKey: 'workflowId'
    })
    paths: Path[];

    @Define.Mapping({
        Mapping: 'WorkflowNodeItem',
        MappingKey: 'workflowId'
    })
    workflowNodeItems: WorkflowNodeItem[] = [];

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    stopConditionId: string;

    @Define.Mapping({
        Mapping: 'Condition',
        MappingKey: 'Id'
    })
    stopCondition: Condition;
}

export const WorkflowStatus = {
    // Disable: 'disable'
}